package com.sskj.mine.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.ui.activity.CodeCheckDialogActivity;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;


public class CodeCheckDialogActivityPresenter extends BasePresenter<CodeCheckDialogActivity> {
    /**
     * 获取邮箱验证码---codeType 1代表注册  2代表重置密码
     *
     * @param email 邮箱号
     * @return
     */
    public void sendEmailCode(String email) {
        httpService.sendEmailCode(email)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.getMsg());
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.startCount();
                        }
                    }
                });
    }

    /**
     * 获取短信验证码---codeType 1代表注册  2代表重置密码
     *
     * @param mobile 手机号
     * @return
     */
    public void sendCode(String mobile) {
        httpService.sendCode(mobile, "2")
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.msg);
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.startCount();
                        }
                    }
                });
    }
}
